package org.example.common.router;

import lombok.extern.slf4j.Slf4j;
import org.example.module.api.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.Map;

@Service
@Slf4j
public class WarehouseFactory {
    @Autowired
    private Map<String, WarehouseService> serviceMap;

    public WarehouseService getWarehouseService(String code) {
        //遍历map
        Iterator<Map.Entry<String, WarehouseService>> iterator = serviceMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, WarehouseService> next = iterator.next();
            log.debug("next.getValue().getCode():"+next.getValue().getCode());
            if (next.getValue().getCode().equals(code)) {
                return next.getValue();
            }
        }
        return null;
    }
}
